﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;

namespace IHISCETeim.Web.MachineSys.MacModel
{
    public partial class OMarketQualificationList : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.查看, Permission.修改, Permission.新增, Permission.删除, Permission.导出 };
            }
        }
        protected override string DWZRef
        {
            get
            {
                return "OMarketQualificationList";
            }
        }
        #region 属性 (查询条件)

        protected override string orderField
        {
            get
            {
                return string.IsNullOrEmpty(base.orderField) ? "MQID" : base.orderField;
            }
        }
        protected override string orderDirection
        {
            get
            {
                return string.IsNullOrEmpty(base.orderDirection) ? "Desc" : base.orderDirection;
            }
        }


        protected string ItemCode
        {
            get
            {
                return GetRequestValue<string>("ItemCode", "");

            }
        }
        protected string SerialNumber
        {
            get
            {
                return GetRequestValue<string>("SerialNumber", "");

            }
        }
        protected string SupplierName
        {
            get
            {
                return GetRequestValue<string>("SupplierName", "");

            }
        }

        #endregion
        protected string GetWhereSql()
        {
            string wheresql = " 1=1 ";
            if (!string.IsNullOrEmpty(ItemCode))
            {
                wheresql = string.Format(" (itemcode like '%{0}%' or itemname like '%{0}%') ", ItemCode);
            }

            if (!string.IsNullOrEmpty(SerialNumber))
            {
                if (!string.IsNullOrEmpty(wheresql))
                    wheresql += string.Format(" and SerialNumber like '%{0}%'", SerialNumber);
                else
                    wheresql = string.Format(" SerialNumber like '%{0}%'", SerialNumber);
            }
            if (!string.IsNullOrEmpty(SupplierName))
            {
                if (!string.IsNullOrEmpty(wheresql))
                    wheresql += string.Format(" and  SupplerName like '%{0}%'", SupplierName);
                else
                    wheresql = string.Format(" SupplerName like '%{0}%'", SupplierName);
            }


            return wheresql;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            DataBind();
            this.AddLog(Permission.查看, GetWhereSql());
        }

        protected void DataBind()
        {
            this.rpMenu.DataSource = OMarketQualificationController.GetPagination(GetWhereSql(), pageNum, numPerPage, SQLSort, ref TotalCount);
            this.rpMenu.DataBind();
        }
    }
}